﻿
using Demo.Net.SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demo.Net.Service.Service
{
    public class SqlSugarService
    {

        private readonly SqlSugarDBCom _dbCom;

        public SqlSugarService(SqlSugarDBCom dBCom) 
        {
            _dbCom = dBCom;
        }


        /// <summary>
        /// 简单测试 获取全部用户
        /// </summary>
        /// <returns></returns>
        public async Task<List<Tusr_User>> GetTest()
        {
           var userList = await  _dbCom.Tusr_User.AsQueryable().ToListAsync();
            return userList;
        }
        
        /// <summary>
        /// 删除用户测试
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<bool> DeleteUser(int id)
        {
            return await _dbCom.Tusr_User.DeleteByIdAsync(id);
        }


        /// <summary>
        /// 添加用户测试
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public async Task<bool> AddUser(Tusr_User userInfo)
        {
          return await   _dbCom.Tusr_User.InsertAsync(userInfo);
        }
    }
}
